<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
</head> 
<body onpageshow="resetPagination('dg')" style="padding:0px;width:98%">
    {datagrid id="dg" datasource="/invest/StrategyStageStatService/findAll.do"  view="i_strategy_stage_stat"}
    
    <script>
    field_formatters.buy_time=function (value, row, index){
		if(value){
			return value.substring(0,10);
		}
    }
    field_formatters.sell_time=function (value, row, index){
		if(value){
			return value.substring(0,10);
		}
    }
    field_formatters.hold_days=function (value, row, index){
		var endDate = new Date();
		if(row['sell_time'])
			endDate = Date.parse(row['sell_time']);
		return getDaysBetween(row['buy_time'], endDate);
    }
    field_formatters.profit=function (value, row, index){
		if(value){
			return "<font color='red'>"+value+"</font>";
		}
    }
    field_formatters.plan_sell_price=function (value, row, index){
		if(value){
			return parseInt(value * 100) / 100;
		}
    }
    field_formatters.price2=function (value, row, index){
		if(row['profit']){
			return "<font color='red'>"+parseInt((row['sell_price'] - row['buy_price']) * 10000 / row['buy_price']) / 100+"%</font>";
		} else {
			if(row['price'] > row['buy_price']) {
				return "<font color='red'>"+parseInt((row['price'] - row['buy_price']) * 10000 / row['buy_price']) / 100+"%</font>";
			} else {
				return "<font color='green'>"+parseInt((row['price'] - row['buy_price']) * 10000 / row['buy_price']) / 100+"%</font>";
			}
		}
    }
	function  getDaysBetween(dateString1, endDate){
		var  startDate = Date.parse(dateString1);
		if(!endDate) endDate = new Date();
		if (startDate>endDate) {
			return 0;
		}
		if (startDate==endDate) {
			return 1;
		}
		var days=(endDate - startDate)/(1*24*60*60*1000);
		return  parseInt(days);
	}
    </script>
</body>
</html>